Skip to content

feat(vartalaap): add livekit-plugins-vartalaap TTS plugin - #8448

Closed
roshanpuru wants to merge 4 commits into
livekit:mainfrom
vartalaap-si:vartalaap-tts
Closed

roshanpuru wants to merge 4 commits into
livekit:mainfrom
vartalaap-si:vartalaap-tts

Conversation

@roshanpuru

Copy link
Copy Markdown

Summary

Adds livekit-plugins-vartalaap, a TTS plugin for Vartalaap, a Hinglish and Indian-language text-to-speech API (24 kHz pcm16, first audio after the first 80 ms frame).

  • ChunkedStream (synthesize()): POST /v1/tts, the chunked PCM body is forwarded as it arrives.
  • SynthesizeStream (stream()): a pooled WS /v1/tts/stream connection (utils.ConnectionPool, 5 min sessions, prewarm()). Text is cut into sentences as it is pushed (tokenize.basic.SentenceTokenizer, which ends sentences on the Devanagari danda too) and every sentence is sent at once as its own utterance; the server serves them in order and streams each one's audio back, so the next sentence is synthesised while the current one plays. Events and audio of other utterances left on a pooled socket are ignored.
  • Every server parameter is a constructor option and an update_options() keyword: voice, expression (the API's style), digits, speed, temperature, seed, postfx, profile, raw; they travel in each utterance's body, so updates apply from the next sentence without reconnecting.
  • 503 (busy, Retry-After) and 5xx are retryable APIStatusErrors, 4xx are not; handshake errors never carry the key.
  • tests/test_plugin_vartalaap_tts.py (pytest.mark.plugin("vartalaap")): request body, validation, key redaction, in-order playback with stale leftovers dropped, retryable vs non-retryable errors.

make check (ruff format, ruff check, mypy strict) and the unit tests pass. No version bumps, per CONTRIBUTING.

Measured against the live API (2026-11-08, Mac to Mumbai, warm cache, 8 interleaved iterations)

path TTFA p50 ms (1 sentence) TTFA p50 ms (3 sentences) plugin − raw
raw WebSocket 40.8 40.5
plugin stream() 44.3 45.5 +3.2 / +4.9
raw REST 42.2 46.1
plugin synthesize() 44.4 46.9 +2.1 / +1.5

16 concurrent streams for 20 s: 28.4 audio-seconds per wall-second through the plugin vs 28.0 raw, TTFA p95 116 ms vs 103 ms. Full tables in the plugin's development repo (bench/RESULTS*.md).

🤖 Generated with Claude Code

roshanpuru and others added 3 commits November 7, 2026 22:23
Vartalaap is a Hinglish and Indian-language TTS API. The plugin synthesises over POST /v1/tts
(ChunkedStream, the chunked PCM body forwarded as it arrives) and streams over a pooled
WS /v1/tts/stream (SynthesizeStream): text is cut into sentences as the LLM produces it, every
sentence is sent as its own utterance and the server serves them in order, so the next sentence
is synthesised while the current one plays. Every server parameter (voice, expression, digits,
speed, temperature, seed, postfx, profile, raw) is a constructor option and an update_options
keyword; prewarm() opens the socket ahead of the first turn; handshake errors never carry the key.

Unit tests cover the request body, option validation, key redaction, in-order playback with
stale pooled-socket leftovers dropped, and retryable vs non-retryable server errors.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ence

An error event tagged with another utterance's request_id (a pooled-socket leftover) no
longer fails the current stream; untagged errors still do. SynthesizeStream reads the
owning TTS's options when it sends each sentence, so update_options() between two
sentences applies to the next one on the same socket.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… before applying, expire sockets by lifetime

- the receive loop wakes when the sender finishes with nothing pending, instead of waiting
  for a server message that never comes (a turn whose last sentence ended before the LLM
  closed the input would otherwise hit the receive timeout)
- update_options validates a copy and assigns it only on success
- pooled sockets expire 5 min after they were opened, not 5 min after their last reuse

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +568 to +570
if sender_done.is_set():
return await ws.receive(timeout=self._conn_options.timeout)
recv = asyncio.ensure_future(ws.receive(timeout=self._conn_options.timeout))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Input pause aborts speech mid-reply

When text pauses for ten seconds after a sentence, _recv_task times out despite having no pending utterance. Previously delivered audio prevents a retry, so the rest of the reply is lost.

Learn more

The input channel can remain open while an LLM waits for a tool or generates its next sentence. After the server ends the previous utterance, pending is empty but sender_done is false, so _recv_task calls ws.receive(timeout=self._conn_options.timeout) again. The default timeout is ten seconds in APIConnectOptions; a quiet connection triggers APITimeoutError. The base streaming retry loop refuses retries once it has emitted audio.

Example: The agent speaks its first sentence, then waits 12 seconds for a tool result before pushing the second. The stream raises a timeout at ten seconds, and the second sentence never plays.

Recommended fix: When pending is empty and the sender is still accepting input, wait for the next send or sender completion without a socket receive deadline. Apply the receive timeout only while an utterance awaits server audio, and keep handling unexpected connection closure during idle periods.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

With no utterance in flight the pause between sentences is the LLM's, not the server's, so
the stream waits for the next sentence or the end of input without a deadline; the
connection timeout applies only while the server owes a message.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@roshanpuru

Copy link
Copy Markdown
Author

Superseded by #8449: the plugin is renamed to Vartaloop (livekit-plugins-vartaloop).

@roshanpuru roshanpuru closed this Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant